import logo from './logo.svg';
import './App.css';
import {BrowserRouter as Router,Switch,Route,Redirect}from 'react-router-dom';
import{adminRoutes}from './routers';
import Frame from './components/Frame/index';
import {isLogined}from './utils/auth';
function App(props) {

  return isLogined()?( 
  <Frame>
        <Switch>
          {
            adminRoutes.map(route=>{
              return(
                <Route
                key={route.path}
                path={route.path}
                exact={route.exact}
                render={routeProps=>{
                  return <route.component {...routeProps}/>
                }}
                />
              )
            })
          }
          <Redirect to={adminRoutes[0].path} from="/admin"/>
          <Redirect to="/404"/>
        </Switch>
    </Frame>):(<Redirect to="/login"/>)
  
}
export default App;